/*
 * @Author: your name
 * @Date: 2021-07-28 17:33:27
 * @LastEditTime: 2021-07-28 17:36:16
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /shb-pc-fe/src/modules/productV2/productView/components/methods/update.js
 */
import { TaskFieldNameMappingEnum } from '@model/enum/FieldMappingEnum.ts';
import { triggerConnectorUpdate } from '@src/util/assist';

export default {
  update({ field, newValue, oldValue }) {
    let { fieldName, displayName } = field;

    if (this.$appConfig.debug) {
      console.info(
        `[FormBuilder] ${displayName}(${fieldName}) : ${JSON.stringify(
          newValue
        )}`
      )
    }

    let value = this.value;
    this.$set(value, fieldName, newValue);

    triggerConnectorUpdate(this, field);

  },
  /** 
   * @description 更新地址数据
  */
  updateAddressValue(value) {
    this.update({ field: { fieldName: TaskFieldNameMappingEnum.Address }, newValue: value });
  },
  /** 
   * @description 更新客户数据
  */
  updateCustomerValue(value) {
    this.update({ field: { fieldName: TaskFieldNameMappingEnum.Customer }, newValue: value });
  },
  /** 
   * @description 更新联系人数据
  */
  updateLinkmanValue(value) {
    this.update({ field: { fieldName: TaskFieldNameMappingEnum.Linkman }, newValue: value });
  },
}